package com.imufe.chemicalenterprisedangerwarning.controller;

import com.imufe.chemicalenterprisedangerwarning.entity.po.IndustryPO;
import com.imufe.chemicalenterprisedangerwarning.entity.vo.IndustryVO;
import com.imufe.chemicalenterprisedangerwarning.service.IndustryService;
import com.imufe.chemicalenterprisedangerwarning.common.ResponseEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 行业类别表 前端控制器
 * </p>
 *
 * @author BaiBan
 * @since 2022-09-22
 */
@Api(tags = "企业相关")
@RestController
@RequestMapping("/industry")
public class IndustryController {

    @Autowired
    IndustryService service;

    @ApiOperation(value = "", hidden = true)
    @PostMapping("/create")
    public void create(String name) {
        IndustryPO po = new IndustryPO();
        po.setName(name);
        service.save(po);
    }

    @ApiOperation(value = "行业类别选项表", notes = "创建或修改行业类别时下拉选项表")
    @GetMapping("/option/list")
    public ResponseEntity<List<IndustryVO>> list() {
        return ResponseEntity.success(service.optionList());
    }
}